package com.zkingsoft.laqeelin.action;

import static com.zkingsoft.common.constance.AppConstance.*;

import com.matrix.core.constance.SystemMessageCode;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.web.BaseAction;
import com.matrix.core.constance.SystemErrorCode;
import com.matrix.core.anotations.RemoveRequestToken;
import com.zkingsoft.laqeelin.service.BizOrderService;
import com.zkingsoft.laqeelin.service.BizQrcodeService;

import org.springframework.stereotype.Controller;

import com.matrix.core.exception.GlobleException;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.matrix.core.anotations.SaveRequestToken;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.WebUtil;

import org.springframework.beans.factory.annotation.Autowired;

import com.zkingsoft.laqeelin.bean.BizOrder;
import com.zkingsoft.laqeelin.bean.BizQrcode;

/**
 * @description (二维码记录表)
 * @author 何明
 * @date 2018-09-26 18:31
 */
@Controller
@RequestMapping(value = "bizQrcode")
public class BizQrcodeAction extends BaseAction{

	@Autowired
	private BizQrcodeService bizQrcodeService;
	
	//记录编辑前的值Before_Edit_Value
	public static final String BEV="BizQrcode_BEV";
	
	
	/**
	 * 列表显示
	 */
	@RequestMapping(value =  SAFEPATH+"/showList")
	public @ResponseBody AjaxResult showList(BizQrcode bizQrcode, PaginationVO pageVo) {
		return showList(bizQrcodeService, bizQrcode, pageVo);
	}
   	
	/**
	 * 新增
	 */   
	@RemoveRequestToken	
   	@RequestMapping(value =  SAFEPATH+"/addBizQrcode")
	public @ResponseBody AjaxResult addBizQrcode(BizQrcode bizQrcode) {
	 	int i=bizQrcodeService.add(bizQrcode);
	 	if(i > 0){
	 		return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, "(二维码记录表)");
	 	}else {
			throw new GlobleException(SystemErrorCode.DATA_ADD_FAIL);
		}
	}
	
	
	
	
	
	/**
	 * 修改
	 */   
	@RemoveRequestToken	
   	@RequestMapping(value =  SAFEPATH+"/modifyBizQrcode")
	public @ResponseBody AjaxResult modifyBizQrcode(BizQrcode bizQrcode) {
	   		bizQrcode.setCodeId(((BizQrcode)WebUtil.getSessionAttribute(BEV)).getCodeId());
	   		AjaxResult result=modify(bizQrcodeService, WebUtil.getSessionAttribute(BEV), bizQrcode, "(二维码记录表)");
			WebUtil.removeSessionAttribute(BEV);
			return  result;
	}
	
	
	
	
   	/**
	 * 进入修改界面
	 */   
	@SaveRequestToken
   	@RequestMapping(value =  SAFEPATH+"/editForm")
	public String editForm(Long id) {
		BizQrcode bizQrcode;
		if (id != null) {
			bizQrcode = bizQrcodeService.findById(id);
			WebUtil.getRequest().setAttribute("obj", bizQrcode);
			WebUtil.setSessionAttribute(BEV, bizQrcode);
		}
		return "admin/BizQrcode-form";
	}
   	
   	
   	/**
	 * 删除
	 */  
 	@RequestMapping(value = SAFEPATH+"/del")
	public @ResponseBody AjaxResult del(String keys) {
		return remove(bizQrcodeService, keys);
	}
  
}